{% extends "base.html" %}
{% block title %}Monitor Views Show{% endblock %}
{% block content %}
<div class="col-lg-12">
    <div class="panel panel-info ">
        <div class="panel-heading">监控推送系统接收信息表</div>
        <div class="panel-body">
            <table class="table table-striped">
                <thead>
                    <td><b>主机名</b></td>
                    <td><b>CPU信息</b></td>
                    <td><b>内存信息</b></td>
                    <td><b>磁盘信息</b></td>
                    <td><b>登陆用户数</b></td>
                    <td><b>进程数</b></td>
                    <td><b>更新时间</b></td>
                </thead>
                <tbody>
                {% if result %}
                    {% if result.get('code',1) == 0 %}
                        {% if result['data'] %}
                            {% for host in result['data'] %}
                                <tr>
                                    <td><b>{{ host.hostname }}</b>( {{ host.system }} )</td>
                                    <td>
                                        CPUS使用率：({{ host.cpus.cpu_count }}C/{{ host.cpus.cpu_logical_count }}L)<br>
                                        <div class="progress">
                                        {% if host.cpus.cpu_percent >= 70 %}
                                            <div class="progress-bar progress-bar-danger progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="{{ host.cpus.cpu_percent }}" aria-valuemax="100" style="width: {{ host.cpus.cpu_percent }}%;min-width: 40px;">
                                        {% else %}
                                            <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="{{ host.cpus.cpu_percent }}" aria-valuemax="100" style="width: {{ host.cpus.cpu_percent }}%;min-width: 40px;">
                                        {% endif %}

                                            {{ host.cpus.cpu_percent }}%
                                          </div>
                                        </div>
                                    </td>
                                    <td>
                                        物理内存({{ host.mems.virtual_memory.vm_total }}GB)：
                                        <div class="progress">
                                        {% if host.mems.virtual_memory.vm_percent >= 70 %}
                                            <div class="progress-bar progress-bar-danger progress-bar-striped active" role="progressbar" aria-valuenow="{{ host.mems.virtual_memory.vm_percent }}" aria-valuemin="2" aria-valuemax="100" style="width: {{ host.mems.virtual_memory.vm_percent }}%;min-width: 40px;">
                                        {% else %}
                                            <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="{{ host.mems.virtual_memory.vm_percent }}" aria-valuemin="2" aria-valuemax="100" style="width: {{ host.mems.virtual_memory.vm_percent }}%;min-width: 40px;">
                                        {% endif %}

                                            {{ host.mems.virtual_memory.vm_percent }}%
                                          </div>
                                        </div>

                                        {% if host.mems.swap %}
                                            SWAP({{ host.mems.swap.swap_total }}GB)：
                                            <div class="progress">
                                            {% if host.mems.swap.swap_percent > 20 %}
                                                <div class="progress-bar progress-bar-danger progress-bar-striped active" role="progressbar" aria-valuenow="{{ host.mems.swap.swap_percent }}" aria-valuemin="2" aria-valuemax="100" style="width: {{ host.mems.swap.swap_percent }}%;min-width: 40px;">
                                            {% else %}
                                                <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="{{ host.mems.swap.swap_percent }}" aria-valuemin="2" aria-valuemax="100" style="width: {{ host.mems.swap.swap_percent }}%;min-width: 40px;">
                                            {% endif %}
                                                {{ host.mems.swap.swap_percent }}%
                                              </div>
                                            </div>
                                        {% endif %}

                                    </td>
                                    <td>
                                        {% for key in host.disks.disks %}
                                            {{ key }}分区({{ round(host.disks.disks[key].total/1024/1024/1024) }}GB)：
                                            <div class="progress">
                                            {% if host.disks.disks[key].percent >= 70 %}
                                                <div class="progress-bar progress-bar-danger progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="{{ host.disks.disks[key].percent }}" aria-valuemax="100" style="width: {{ host.disks.disks[key].percent }}%;min-width: 40px;">
                                            {% else %}
                                                <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="{{ host.disks.disks[key].percent }}" aria-valuemax="100" style="width: {{ host.disks.disks[key].percent }}%;min-width: 40px;">
                                            {% endif %}
                                                {{ host.disks.disks[key].percent }}%
                                              </div>
                                            </div>
                                        {% endfor %}
                                    </td>
                                    <td>登陆数：{{ host.users.count }}</td>
                                    <td>进程数：{{ host.pids.count }}</td>
                                    <td>{{  time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(host.timestamp))  }}</td>
                                </tr>
                            {% endfor %}
                        {% endif %}
                    {% endif %}
                {% else %}
                {% endif %}
                </tbody>
            </table>
        </div>
        <div class="panel-footer">
            <div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate" >
                <ul class="pagination">
                    <li class="paginate_button previous disabled" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_previous">
                        <a href="#">Previous</a></li>
                    <li class="paginate_button active" aria-controls="dataTables-example" tabindex="0">
                        <a href="#">1</a></li>
                    <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
                        <a href="#">2</a></li>
                    <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
                        <a href="#">3</a></li>
                    <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
                        <a href="#">4</a></li>
                    <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
                        <a href="#">5</a></li>
                    <li class="paginate_button " aria-controls="dataTables-example" tabindex="0">
                        <a href="#">6</a></li>
                    <li class="paginate_button next" aria-controls="dataTables-example" tabindex="0" id="dataTables-example_next">
                        <a href="#">Next</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

{% endblock %}